﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using NHibernate;
using NHibernate.Cfg;
using TeamCommunitySolution.Extensions;
using TeamCommunitySolution.Domain.DataLayer.Base;
using TeamCommunitySolution.Modules.Base;
using TeamCommunitySolution.Repositories.Base;
using TeamCommunitySolution.Modules.Base.Requests;

namespace TeamCommunitySolution
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static string HostName = ConfigurationManager.AppSettings["HostName"].ToString();
        public const string UserIndex = "UserIndex";

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new ThemeViewEngine());

        }

        public static IList<SelectListItem> YearList
        {
            get
            {
                IList<SelectListItem> output = new List<SelectListItem>();

                for(int i = DateTime.Now.Year - 60; i < DateTime.Now.Year; i++)
                {
                    SelectListItem item = new SelectListItem();
                    item.Text = i.ToString();
                    item.Value = i.ToString();
                    output.Add(item);
                }

                return output;
            }
        }

        public static IList<SelectListItem> MonthList
        {
            get
            {
                IList<SelectListItem> output = new List<SelectListItem>();

                for (int i = 1; i < 13; i++)
                {
                    SelectListItem item = new SelectListItem();
                    item.Text = i.ToString();
                    item.Value = i.ToString();
                    output.Add(item);
                }

                return output;
            }
        }

        public static IList<SelectListItem> DayList
        {
            get
            {
                IList<SelectListItem> output = new List<SelectListItem>();

                for (int i = 1; i < 32; i++)
                {
                    SelectListItem item = new SelectListItem();
                    item.Text = i.ToString();
                    item.Value = i.ToString();
                    output.Add(item);
                }

                return output;
            }
        }
    }
}